home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 11841 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.1 KB  |  45 lines

  1. Path: nntp.teleport.com!usenet
  2. From: GHouck <hksys@teleport.com>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Newbie needs help w/ARGV ARGC
  5. Date: Tue, 26 Mar 1996 14:57:07 -0800
  6. Organization: systems hk
  7. Message-ID: <31587643.6355@teleport.com>
  8. References: <4j4ja1$dc3@mtinsc01-mgt.ops.worldnet.att.net>
  9. NNTP-Posting-Host: ip-pdx02-38.teleport.com
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.01 (WinNT; I)
  14.  
  15. Raymond Joh wrote:
  16. > I just want to be able to enter two file paths at the command line.
  17. > Here is my code:
  18. > #include <stdio.h>
  19. > #include <stdlib.h>
  20. > main(int argc, char *argv[],char *envp[])
  21. > {
  22. > FILE *ofp,*nfp;
  23. > char ch;
  24. > gets(*argv);
  25. > if (argc!=3)
  26. >   {
  27. >   printf("Enter: <source> <destination>\n");
  28. >   exit(1);
  29. >   }
  30. > Code countinues but when I enter my command line input such as:
  31. > A:\readme.txt  A:\newfile.txtRaymond,
  32. You do not 'gets' the command-line arguments; you are given an
  33. array of pointers to strings, so treat them as a list of char
  34. strings:
  35.  
  36.   ...
  37.   if( argc >= 3 ) {
  38.     strcpy( file1,argv[1] );
  39.     strcpy( file2,argv[2] );
  40.   ...
  41. Yours, Geoff Houck
  42.